<?php
//注意，所有的控制器类都要继承Model类
class index extends Control{
	
	// dedecms mvc中的控制器方法，一律需要添加前缀 ac_ ，这是必须这么做的
    function ac_index(){
        echo "这里是dedecms API开发教程<br/>";
		echo "<a href='index.php?ct=article&ac=artlist'>列出文章</a>";
	}

	//百度提交url
	function ac_posturl(){
		$urls = array(
			'https://domain/1.html',
			'https://domain/2.html',
		);
		$api = 'http://data.zz.baidu.com/urls?appid=&token=&type=batch';
		$result = $this->http_request($api);
		echo $result;
	}

	
	//get,post
	function http_request($url, $data = null){
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_URL, $url);
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
		if (!empty($data)) {
		  curl_setopt($curl, CURLOPT_POST, 1);
		  curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
		}
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
		$info = curl_exec($curl);
		curl_close($curl);
		return $info;
  }

}
